<template>
    <view class="main">
        <uni-nav-bar left-icon="left" :statusBar="true" titleSize="30px" leftText="返回" rightText="提交"
            :title="formData.id?'修改租赁订单':'新增租赁订单'" @clickLeft="back" @clickRight="addBtn" :fixed="true"
            backgroundColor="#3286ed" color="#fff"></uni-nav-bar>
        <view :class="{popupShow:popupShow}">
            <u--form class="form" labelPosition="left" labelWidth="120px" :model="formData" :rules="rules" ref="form">
                <u-form-item leftIcon="*" leftIconStyle="color:red;" @click="show=1" label="合同模板" prop="contractTemplateDuo" borderBottom ref="item1">
                    <u--input disabled disabledColor="#fff" v-model="formData.contractTemplateDuo" border="none"
                        placeholder="合同模板"></u--input>
                    <u-icon slot="right" name="arrow-right"></u-icon>
                </u-form-item>

                <u-form-item label="合同上传" borderBottom>
                    <file-upload @update="update"></file-upload>
                </u-form-item>

                <u-form-item leftIcon="*" leftIconStyle="color:red;" label="发起人" prop="sponsorName" borderBottom ref="item1">
                    <u--input disabled disabledColor="#fff" v-model="formData.sponsorName" border="none"
                        placeholder="发起人"></u--input>
                    <!-- <u-icon slot="right" name="arrow-right"></u-icon> -->
                </u-form-item>

                <u-form-item leftIcon="*" leftIconStyle="color:red;" label="发起人所属部门" prop="sponsorDeptName" borderBottom ref="item1">
                    <u--input disabled disabledColor="#fff" v-model="formData.sponsorDeptName" border="none"
                        placeholder="发起人所属部门"></u--input>
                    <!-- <u-icon slot="right" name="arrow-right"></u-icon> -->
                </u-form-item>

                <u-form-item leftIcon="*" leftIconStyle="color:red;" @click="userBtn(1)" label="业务员" prop="salesmanName" borderBottom ref="item1">
                    <u--input disabled disabledColor="#fff" v-model="formData.salesmanName" border="none"
                        placeholder="业务员"></u--input>
                    <u-icon slot="right" name="arrow-right"></u-icon>
                </u-form-item>

                <u-form-item  label="协同人" prop="collaboratorName" borderBottom ref="item1">
                    <u--input  v-model="formData.collaboratorName" border="none"
                        placeholder="请选择协同人"></u--input>
                    <u-icon @click="userBtn(2)" slot="right" name="arrow-right"></u-icon>
                </u-form-item>
                <u-form-item leftIcon="*" leftIconStyle="color:red;" label="订单编号" prop="orderNo" borderBottom ref="item1">
                    <u--input disabled disabledColor="#fff"  v-model="formData.orderNo" border="none" placeholder="订单编号">
                    </u--input>
                </u-form-item>
                <u-form-item leftIcon="*" leftIconStyle="color:red;" @click="orderDateShow=true" label="订单发起日期" prop="orderDate" borderBottom ref="item1">
                    <u--input disabled disabledColor="#fff" v-model="formData.orderDate" border="none"
                        placeholder="订单发起日期"></u--input>
                </u-form-item>

                <u-form-item leftIcon="*" leftIconStyle="color:red;" @click="show=2" label="业务所属公司" prop="businessCompanyDuo" borderBottom ref="item1">
                    <u--input disabled disabledColor="#fff" v-model="formData.businessCompanyDuo" border="none"
                        placeholder="业务所属公司"></u--input>
                    <u-icon slot="right" name="arrow-right"></u-icon>
                </u-form-item>
                  <u-form-item  leftIcon="*" leftIconStyle="color:red;" label="客户姓名" prop="customerName" borderBottom ref="item1">
                    <u--input  v-model="formData.customerName" border="none" placeholder="客户姓名">
                    </u--input>
                    <u-icon slot="right" @click="customerBtn" name="arrow-right"></u-icon>
                </u-form-item>
				</u-form-item>
				  <u-form-item leftIcon="*" leftIconStyle="color:red;"  label="联系人名称" prop="contactName" borderBottom ref="item1">
				    <u--input  v-model="formData.contactName" border="none" placeholder="联系人名称">
				    </u--input>
				    <u-icon slot="right" @click="customerBtn" name="arrow-right"></u-icon>
				</u-form-item>
				<u-form-item leftIcon="*" leftIconStyle="color:red;" label="客户联系方式" prop="contactTelephone" borderBottom ref="item1">
				    <u--input  v-model="formData.contactTelephone" border="none" placeholder="客户联系方式">
				    </u--input>
				</u-form-item>
                <u-form-item @click="show=11" label="客户类别" prop="customerCategoryName" borderBottom ref="item1">
                    <u--input disabled disabledColor="#fff" v-model="formData.customerCategoryName" border="none"
                        placeholder="客户类别"></u--input>
                    <u-icon slot="right" name="arrow-right"></u-icon>
                </u-form-item>
                <u-form-item leftIcon="*" leftIconStyle="color:red;"  @click="show=12" label="客户信息来源" prop="customerSourceName" borderBottom ref="item1">
                    <u--input disabled disabledColor="#fff" v-model="formData.customerSourceName" border="none"
                        placeholder="客户信息来源"></u--input>
                    <u-icon slot="right" name="arrow-right"></u-icon>
                </u-form-item>
                <u-form-item @click="show=13" label="客户所属省份" prop="customerRegion" borderBottom ref="item1">
                    <u--input disabled disabledColor="#fff" v-model="formData.customerRegion" border="none"
                        placeholder="客户所属省份"></u--input>
                    <u-icon slot="right" name="arrow-right"></u-icon>
                </u-form-item>
                <u-form-item leftIcon="*" leftIconStyle="color:red;" @click="show=3" label="订单类型" prop="orderTypeDuo" borderBottom ref="item1">
                    <u--input disabled disabledColor="#fff" v-model="formData.orderTypeDuo" border="none"
                        placeholder="订单类型"></u--input>
                    <u-icon slot="right" name="arrow-right"></u-icon>
                </u-form-item>
                <u-form-item leftIcon="*" leftIconStyle="color:red;" label="项目名称" prop="projectName" borderBottom ref="item1">
                    <u--input v-model="formData.projectName" border="none" placeholder="项目名称"></u--input>
                    <u-icon @click="openProjict" slot="right" name="arrow-right"></u-icon>
                </u-form-item>
                <u-form-item leftIcon="*" leftIconStyle="color:red;" @click="show=4" label="项目区域" prop="projectArea" borderBottom ref="item1">
                    <u--input disabled disabledColor="#fff" v-model="formData.projectArea" border="none"
                        placeholder="项目区域"></u--input>
                    <u-icon slot="right" name="arrow-right"></u-icon>
                </u-form-item>
                <u-form-item leftIcon="*" leftIconStyle="color:red;"  @click="show=5" label="项目信息来源" prop="projectSourceName" borderBottom ref="item1">
                    <u--input disabled disabledColor="#fff" v-model="formData.projectSourceName" border="none"
                        placeholder="项目信息来源"></u--input>
                    <u-icon slot="right" name="arrow-right"></u-icon>
                </u-form-item>
				<u-form-item  leftIcon="*" leftIconStyle="color:red;" label="信息提供人" prop="informationProviderName" borderBottom ref="item1">
				    <u--input   v-model="formData.informationProviderName" border="none"
				        placeholder="信息提供人"></u--input>
				     
				</u-form-item>
				<u-form-item  leftIcon="*" leftIconStyle="color:red;" label="信息提供状态" prop="informationProviderName" borderBottom ref="item1">
				    <u--input   v-model="formData.informationProviderName" border="none"
				        placeholder="信息提供状态"></u--input>
				     
				</u-form-item>
				<u-form-item  leftIcon="*" leftIconStyle="color:red;" label="业务费情况" prop="businessExpenses" borderBottom ref="item1">
				    <u--input v-model="formData.businessExpenses" border="none" placeholder="业务费情况"></u--input>
				</u-form-item>
                <u-form-item leftIcon="*" leftIconStyle="color:red;"  @click="adressFn" label="收货地址" prop="address" borderBottom ref="item1">
                    <u--input :readonly="true" v-model="formData.address" border="none" placeholder="收货地址"></u--input>
                    <u-icon slot="right" name="arrow-right"></u-icon>
                </u-form-item>
				<view class="adress">
					<u-textarea v-model="formData.address" placeholder="收货地址"></u-textarea>
					<view class="map" @click="mapFn">
						<u-icon  customStyle="margin: 0 auto;line-height: 40px;" name="map"></u-icon>
					</view>
				</view>
                <u-form-item leftIcon="*" leftIconStyle="color:red;" label="项目联系人" prop="consigneeName" borderBottom ref="item1">
                    <u--input v-model="formData.consigneeName" border="none" placeholder="项目联系人"></u--input>
                    <!-- <u-icon slot="right" name="arrow-right"></u-icon> -->
                </u-form-item>
                <u-form-item leftIcon="*" leftIconStyle="color:red;" label="联系人电话" prop="consigneeTel" borderBottom ref="item1">
                    <u--input v-model="formData.consigneeTel" border="none" placeholder="联系人电话"></u--input>
                    <!-- <u-icon slot="right" name="arrow-right"></u-icon> -->
                </u-form-item>
               
                <u-form-item leftIcon="*" leftIconStyle="color:red;" @click="show=6" label="租赁形式" prop="leaseName" borderBottom ref="item1">
                    <u--input disabled disabledColor="#fff" v-model="formData.leaseName" border="none"
                        placeholder="租赁形式"></u--input>
                    <u-icon slot="right" name="arrow-right"></u-icon>
                </u-form-item>
                <u-form-item leftIcon="*" leftIconStyle="color:red;" @click="checkWhouse" label="发货仓库" prop="deliveryWarehouseName" borderBottom ref="item1">
                    <u--input disabled disabledColor="#fff" v-model="formData.deliveryWarehouseName" border="none"
                        placeholder="发货仓库"></u--input>
                    <u-icon slot="right" name="arrow-right"></u-icon>
                </u-form-item>
                <u-form-item leftIcon="*" leftIconStyle="color:red;" @click="productListFn(formData.deliveryWarehouseName)" label="关联产品" borderBottom ref="item1">
                    <u--input disabled disabledColor="#fff" border="none" placeholder="关联产品"></u--input>
                    <u-icon slot="right" name="arrow-right"></u-icon>
                </u-form-item>

                <view v-if="productList.length>0" style="background-color: #fff;">
                    <view style="display: flex;justify-content: space-between;margin:10px;">
                        <view style="width:20%;text-align:center;">整机品名</view>
                        <view style="width:20%;text-align:center;">型号</view>
                        <view style="width:20%;text-align:center;">数量</view>
                        <view v-if="!lumShow" style="width:20%;text-align:center;">日租金</view>
                        <view style="width:20%;text-align:center;">操作</view>
                    </view>
                    <view v-for="(item,index) in  productList" :key="index"
                        style="display: flex;justify-content: space-between;margin:10px;">
                        <view style="width:20%;text-align:center;">{{item.productName}}</view>
                        <view style="width:20%;text-align:center;">{{item.model}}</view>
                        <view  style="width:20%;text-align:center;padding:5px;">
                            <u--input @blur="numberFn(index,item)" v-model="item.quantity"></u--input>
                        </view>
                        <view v-if="!lumShow" style="width:20%;text-align:center;padding:5px;">
                            <u--input v-model="item.dailyRent" @blur="setDailyTotalRent(index,item.dailyRent)"></u--input>
                        </view>
                        <view style="width:20%;text-align:center;" @click="removeProduct(index)">删除</view>
                    </view>
                </view>
				<u-form-item leftIcon="*" leftIconStyle="color:red;" label="辅料说明" prop="accessoriesInstruction" borderBottom ref="item1">
				    <u-textarea v-model="formData.accessoriesInstruction" border="none" placeholder="辅料说明"></u-textarea>
				    <!-- <u-icon slot="right" name="arrow-right"></u-icon> -->
				</u-form-item>
				<u-form-item leftIcon="*" leftIconStyle="color:red;" v-if="lumShow" label="包干金额" prop="lumpAmount" borderBottom ref="item1">
				    <u--input v-model="formData.lumpAmount" border="none" placeholder="包干总金额"></u--input>
				    <!-- <u-icon slot="right" name="arrow-right"></u-icon> -->
				</u-form-item>
				<u-form-item leftIcon="*" leftIconStyle="color:red;" v-if="lumShow" label="包干情况说明" prop="lumpRemark" borderBottom ref="item1">
				    <u-textarea v-model="formData.lumpRemark" border="none" placeholder="情况说明"></u-textarea>
				    <!-- <u-icon slot="right" name="arrow-right"></u-icon> -->
				</u-form-item>
                <u-form-item leftIcon="*" leftIconStyle="color:red;" v-if="!lumShow" label="日租金合计" prop="totalDailyRent" borderBottom ref="item1">
                    <u--input :readonly="false" v-model="formData.totalDailyRent" border="none" placeholder="日租金"></u--input>
                    <!-- <u-icon slot="right" name="arrow-right"></u-icon> -->
                </u-form-item>

                <u-form-item leftIcon="*" leftIconStyle="color:red;" label="应收押金" prop="depositReceivable" borderBottom ref="item1">
                    <u--input :readonly="false" v-model="formData.depositReceivable" border="none" placeholder="应收押金"></u--input>
                </u-form-item>
 <u-form-item leftIcon="*" leftIconStyle="color:red;" @click="show=9" label="押金收取方式" prop="depositCollectionMethodName" borderBottom ref="item1">
                    <u--input disabled disabledColor="#fff" v-model="formData.depositCollectionMethodName" border="none"
                        placeholder="押金收取方式"></u--input>
                    <u-icon slot="right" name="arrow-right"></u-icon>
                </u-form-item>
                <u-form-item leftIcon="*" leftIconStyle="color:red;" label="实收押金" prop="receivedAmount" borderBottom ref="item1">
                    <u--input @blur="receivedFn" v-model="formData.receivedAmount" border="none" placeholder="已收金额"></u--input>
                </u-form-item>

               
                <u-form-item label="转账凭证" prop="enclosure" borderBottom ref="item1">
                    <u--input disabled disabledColor="#fff" v-model="formData.enclosure" border="none" placeholder="附件">
                    </u--input>
                    <u-icon slot="right" name="arrow-right"></u-icon>
                    <u-upload :fileList="fileList1" @afterRead="afterRead" @delete="deletePic" name="1" multiple
                        :maxCount="10"></u-upload>
                </u-form-item>
                <u-form-item leftIcon="*" leftIconStyle="color:red;"  label="期望到货日期" prop="expectedArrivalDate"
                    borderBottom ref="item1">
                    <u--input :clearable="true"  disabledColor="#fff" v-model="formData.expectedArrivalDate" border="none"
                        placeholder="期望到货日期"></u--input>
                    <u-icon slot="right" name="arrow-right" @click="expectedArrivalDateShow=true"></u-icon>
                </u-form-item>
				<u-form-item leftIcon="*" leftIconStyle="color:red;" @click="arrangeShow=true" label="是否需要安排车辆" prop="logisticsName" borderBottom ref="item1">
				    <u--input disabled disabledColor="#fff" border="none" v-model="formData.logisticsName"
				        placeholder="是否需要安排车辆"></u--input>
				    <u-icon slot="right" name="arrow-right"></u-icon>
				</u-form-item>
				<u-form-item v-if="formData.logisticsName=='是'" leftIcon="*" leftIconStyle="color:red;"  @click="show=8" label="运输方式" prop="shippingTypeName" borderBottom ref="item1">
				    <u--input :readonly="true" v-model="formData.shippingTypeName" border="none" placeholder="运输方式">
				    </u--input>
				    <u-icon slot="right" name="arrow-right"></u-icon>
				</u-form-item>
                <u-form-item  label="情况说明" prop="description" borderBottom ref="item1">
					<u--textarea v-model="formData.description" placeholder="请输入情况说明" ></u--textarea>
                    
                </u-form-item>
				
				

            </u--form>
			

        </view>
        <!-- 合同模板 -->
        <u-picker :closeOnClickOverlay="true" @close="show=false" @cancel="show=false" @confirm="checkedFn"
            :show="show==1" :columns="contractTemplateOptions" keyName="dictLabel"></u-picker>
        <!-- 订单时间 -->
       <!-- <u-datetime-picker :closeOnClickOverlay="true" @close="orderDateShow=false" :show="orderDateShow"
            v-model="dateNow" @confirm="orderDateConfirm" @cancel="orderDateShow=false" mode="date"></u-datetime-picker> -->
        <!-- 期望到货日期 -->
        <u-datetime-picker :closeOnClickOverlay="true" @close="expectedArrivalDateShow=false"
            :show="expectedArrivalDateShow" v-model="dateNow" @confirm="expectedArrivalDateConfirm"
            @cancel="expectedArrivalDateShow=false" mode="date"></u-datetime-picker>
        <!-- 业务所属公司 -->
        <u-picker :closeOnClickOverlay="true" @close="show=false" @cancel="show=false" @confirm="checkedFn"
            :show="show==2" :columns="businessCompanyOptions" keyName="dictLabel"></u-picker>
        <!-- 订单类型 -->
        <u-picker :closeOnClickOverlay="true" @close="show=false" @cancel="show=false" @confirm="checkedFn"
            :show="show==3" :columns="orderTypeOptions" keyName="dictLabel"></u-picker>
        <!-- 项目地区域 -->
        <u-picker :closeOnClickOverlay="true" @close="show=false" @cancel="show=false" @confirm="regionConfirm"
            :show="show==4" :columns="regionOptions" keyName="text">
        </u-picker>
        <!-- 项目地材来源 -->
        <u-picker :closeOnClickOverlay="true" @close="show=false" @cancel="show=false" @confirm="checkedFn"
            :show="show==5" :columns="projectSourceOptions" keyName="dictLabel"></u-picker>
        <!-- z租赁形式leaseOptions -->
        <u-picker :closeOnClickOverlay="true" @close="show=false" @cancel="show=false" @confirm="checkedFn"
            :show="show==6" :columns="leaseOptions" keyName="dictLabel">
        </u-picker>
        <!-- 发货仓库 -->
        <u-picker :closeOnClickOverlay="true" @close="show=false" @cancel="show=false" @confirm="warehouseFn"
            :show="show==7" :columns="deliveryWarehouseOption" keyName="warehouseName"></u-picker>
        <!-- 运输方式 -->
        <u-picker :closeOnClickOverlay="true" @close="show=false" @cancel="show=false" @confirm="checkedFn"
            :show="show==8" :columns="shippingTypeOptions" keyName="dictLabel"></u-picker>
        <!-- 押金收取方式 -->
        <u-picker :closeOnClickOverlay="true" @close="show=false" @cancel="show=false" @confirm="checkedFn"
            :show="show==9" :columns="MoneyOptions" keyName="dictLabel">
        </u-picker>
        <!-- 客户类别 -->
        <u-picker :closeOnClickOverlay="true" @close="show=false" @cancel="show=false" @confirm="checkedFn"
            :show="show==11" :columns="customerCategory" keyName="dictLabel"></u-picker>
        <!-- 客户信息来源 -->
        <u-picker :closeOnClickOverlay="true" @close="show=false" @cancel="show=false" @confirm="checkedFn"
            :show="show==12" :columns="customerSource" keyName="dictLabel"></u-picker>
        <!-- 项目地区域 -->
        <u-picker :closeOnClickOverlay="true" @close="show=false" @cancel="show=false" @confirm="customerRegion"
            :show="show==13" :columns="regionOptions" keyName="text"></u-picker>
        <!-- 是否超权限审批 -->
        <u-picker :closeOnClickOverlay="true" @close="show=false" @cancel="show=false" @confirm="checkedFn"
            :show="show==14" :columns="approvaloptions" keyName="dictLabel"></u-picker>
        <!-- 收货地址 -->
        <uni-data-picker class="picker" v-if="show==10" v-model="formData.address" :localdata="addresslist"
            popup-title="选择地址" @change="onchange" ref="adress"></uni-data-picker>
       <!-- 是否安排车辆 -->
	   <u-picker :closeOnClickOverlay="true" @close="arrangeShow=false"  @confirm="arrangeFn" @cancel="arrangeShow=false" :show="arrangeShow" :columns="arrangeOptions" keyName="dictLabel"></u-picker>
		
		<!-- 右边弹框 -->
        <u-popup :closeable="true" :show="rightShow" :closeOnClickOverlay='true' @close="closeMenu"
            overlayStyle="margin-top:88rpx;" customStyle="margin-top:88rpx;" mode="right" round="15px">
            <!-- 搜索条件 -->
            <view>
                <u--form :model="SearcProject" labelWidth="100px">
                    <u-cell>
                        <template #title>
                            <view style="font-size: 14px;color: #fd9540;min-width:200px;">筛选</view>
                        </template>
                    </u-cell>
                    <u-form-item style="margin-left: 16px;" borderBottom label="项目名" prop="projectName">
                        <u--input v-model="SearcProject.projectName" border="none" placeholder='请输入项目名'></u--input>

                    </u-form-item>
                    <u-form-item style="margin-left: 16px;" borderBottom label="客户名" prop="customerName">
                        <u--input v-model="SearcProject.customerName" border="none" placeholder='请输入客户名'></u--input>

                    </u-form-item>

                </u--form>
                <u-button type="success" style='width: 150px;margin-top: 10px;' text="查询" @click="SeacrchP"></u-button>
            </view>
            <view class="projectBox">
                <scroll-view style="height: 500px;" show-scrollbar='true' scroll-y="true" scroll-with-animation='true'>
                    <view class="info" v-for="(item,index) in projectList" :key="item.id">
                        <view>客户姓名:{{item.customerName}}</view>
                        <view>负责人:{{item.userName}}</view>
                        <view>项目名:{{item.projectName}}</view>
                        <view>项目联系人:{{item.receiverName}}</view>
                        <view>项目联系电话:{{item.projectTel}}</view>
                        <view>项目地址:{{item.projectAddress}}</view>
                        <view class="btn" @click="checkProject(item)">
                            <u-button type="success" size="mini" style="width: 60px;height: 25px;">选择</u-button>
                        </view>
                    </view>
                </scroll-view>
            </view>
        </u-popup>
        <u-toast ref="uToast"></u-toast>
        <u-modal showConfirmButton showCancelButton @confirm="BtnModel" @cancel="BtnShow=false" width="250px"
            :show="BtnShow" title="提示">
            <view class="slot-content">
                <rich-text nodes="是否确认提交?"></rich-text>
            </view>
        </u-modal>
    </view>
</template>
<script>
	import {addLogisticsApi} from '@/api/logistics.js'
    import {
        getLoginUser
    } from '@/api/system/user.js'
    import {
        getDicts
    } from '@/api/dictionary/index.js'
    import {
        provinceNameList
    } from '@/api/region/region.js'
    import {
        listWarehouse
    } from '@/api/warehouse.js'
    import {
        addOrder,
        updateOrder
    } from '@/api/order/order.js'
    import {
        ProjectList,
        addProject
    } from '@/api/project.js'
    import {
        listStock2
    } from '@/api/stock.js'
   
    import {
        listCustomer,
        addCustomer
    } from '@/api/customer.js'
    import FileUpload from '@/pages/dialog/FileUpload.vue'
    import {
        getToken
    } from '@/utils/auth.js'
    export default {
        components: {
            FileUpload
        },
        data() {
            return {
                headers: {
                    Authorization: "Bearer " + getToken(),
                },
			    lumShow:false,
				index:'',
                BtnShow: false, //提示框
                popupShow: false, //禁止滚动穿透
                formData: {
					lumpAmount:'',//包干金额
					lumpRemark:'',//包干情况说明
                    contractTemplate: '1',
					contractTemplateDuo:'租赁订单',
                    sponsor: '',
                    sponsorName: '',
                    orderNo: '',
                    sponsorDept: '',
                    sponsorDeptName: '',
                    salesmanName: '',
                    salesman: '',
                    collaborator: '',
                    collaboratorName: '',
                    informationProvider: '',
                    informationProviderName: '',
                    orderDate: "",
                    businessCompany: '',
                    orderType: '',
                    customerId: '',
                    customerName: '', //客户名称
                    customerCategory: '', //客户类别
                    customerSource: "", //客户信息来源
                    customerRegion: '', //客户所属省份
                    projectName: '', //项目名称
                    projectArea: '', //项目地区域value
                    projectAreaName: '', //项目地区域名字
                    projectSource: '', //项目信息来源
                    lease: '', //租赁形式
                    address: '', //收货地址
                    consigneeName: '', //收货人姓名
                    consigneeTel: '', //收货人电话
                    accessoriesInstruction: '标配~', //辅料说明
                    deliveryWarehouseId: '', //仓库id
                    deliveryWarehouseName: '', //仓库
                    depositReceivable: '', //应收押金
                    depositCollectionMethod: '', //押金收取方式
                    receivables: '', //应收款
                    enclosure: '', //附件
                    businessExpenses: '', //业务费
                    totalDailyRent: '', //日租金
                    totalRant: '', //租金合计
                    expectedArrivalDate: '', //到货日期
                    shippingType: '', //运输方式
                    driverName: '', //司机姓名
                    driverTel: '', //司机联系方式
                    vehicleInformation: '', //车辆信息
                    description: '', //情况说明
                    productList: [],
                    purview: '2', //是否超权限审批
					logistics:'',//是否安排车辆
					logisticsName:'',
                    logisticsCostList:[
						{
							orderId:'',
							orderNo:'',
							shippingType:'',
							orderProperty:'1',
							warehouseName:'',
							outboundNo:'',
							warehousingNo:'',
							driverName:'',
							driverTel:'',
							vehicleInformation:'',
							projectAddress:'',
							logisticsExpenses:'',
							projectName:''
						},
					]
				},
				
					 
 rules: {
    'receivedAmount': { required: true,message: '请输入已收金额', trigger: ['blur', 'change']},
    'contractTemplate': { required: true,message: '请选择合同类型', trigger: ['blur', 'change']},
    'businessCompanyDuo': { required: true,message: '请选择业务所属公司', trigger: ['blur', 'change']},
    'orderTypeDuo': { required: true,message: '请选择订单类型',trigger: ['blur', 'change']},
    'projectName': {required: true,message: '请输入项目名称',trigger: ['blur', 'change']},
    'projectArea': { required: true, message: '请选择想去区域', trigger: ['blur', 'change']},
    'projectSourceName': { required: true, message: '请选择项目信息来源', trigger: ['blur', 'change']},
    'address': { required: true, message: '请选择项目地址',trigger: ['blur', 'change']},
    'consigneeName': {required: true,message: '请输入收货人姓名',trigger: ['blur', 'change']},
    'consigneeTel': [{ type: 'string', required: true, message: '请输入联系电话', trigger: ['blur', 'change']},{
                    validator: (rule, value, callback) => {
                         return uni.$u.test.mobile(value);},
                            message: '手机号码不正确',
                            trigger: ['change', 'blur']
                        }
                    ],
    'customerName': { required: true, message: '请输入客户姓名',trigger: ['blur', 'change']},
    'customerRegion': {required: true, message: '请选择客户区域',trigger: ['blur', 'change']},
    'leaseName': { required: true,message: '请选择租赁形式', trigger: ['blur', 'change']},
    'deliveryWarehouseName': {required: true, message: '请选择发货仓库', trigger: ['blur', 'change']},
	'salesmanName':{required:true,message: '请选择业务员',trigger: ['blur', 'change']},
    'contactName':{required:true,message: '请填写联系人名称',trigger: ['blur', 'change']},
	'informationProviderName':{required:true,message: '请填写信息提供人',trigger: ['blur', 'change']},
	'contactTelephone':{required:true,message: '请填写客户联系方式',trigger: ['blur', 'change']},
	'customerSourceName':{required:true,message: '请选择客户信息来源',trigger: ['blur', 'change']},
	'lumpAmount':{required:true,message: '请输入包干金额',trigger: ['blur', 'change']},
	'lumpRemark':{required:true,message: '请输入包干金额说明',trigger: ['blur', 'change']},
	'shippingTypeName':{required:true,message: '请选择运输方式',trigger: ['blur', 'change']},
	'depositCollectionMethodName':{required:true,message: '请选择押金收取方式',trigger: ['blur', 'change']},
	'expectedArrivalDate':{required:true,message: '请选择期望到货日期',trigger: ['blur', 'change']},
	'logisticsName':{required:true,message: '请选择是否需要安排车辆',trigger: ['blur', 'change']},
	'businessExpenses':{required:true,message: '请填写业务费',trigger: ['blur', 'change']},
	},
	

                customerCategoryOptions: [], //客户类别
                customerCategory: [],
                customerSourceOptions: [], //客户信息来源
                customerSource: [],
                contractTemplateOptions: [], //合同模板
                businessCompanyOptions: [], //业务所属公司
                orderTypeOptions: [], //订单类型
                projectSourceOptions: [], //项目信息来源
                projectSourceOptionsDou: [],
                leaseOptions: [], //z租赁形式
                shippingTypeOptions: [], //运输方式
                MoneyOptions: [], //押金收取方式
                regionOptions: [], //项目区域
                addresslist: [], //收货地址
				arrangeOptions:[],//是否需要安排车辆
                // 选择其弹框
                show: false, //picker
				arrangeShow:false,//是否安排车辆
                dateNow: '', //当前时间
                orderDateShow: false, //时间选择器
                expectedArrivalDateShow: false, //期望到货日期
                rightShow: false, //右侧项目弹框
                SearcProject: {
                    projectName: '',
                    customerName: '',
                },
                projectList: [], //项目列表
                deliveryWarehouseOption: [],
                productList: [], //产品列表
                fileList1: [],
                approvaloptions: [], //是否超权限审批
                contractTemplateOptionsDou: [],
                businessCompanyOptionsDou: [],
                orderTypeOptionsDou: [],
                leaseOptionsDou: [],
                MoneyOptionsDou: [],
                shippingTypeOptionsDou: [],
				arrangeOptionDou:[],
				
            }
        },
        onLoad(e) {
			console.log(e,'订单详情');
            this.formData.orderNo = this.setOrderNo() //租赁订单编号
            this.formData.orderDate = this.getNowTime() //订单创建时间
            this.dateNow = this.getNowTime()
            this.getCustomerCategory() //客户类别
            this.getCustomerSource() //客户信息来源
            this.getContractTemplateOptions()
            this.getBusinessCompanyOptions()
            this.getAreaList()
            this.getOrderTypeOptions()
            this.getProjectSourceOptions()
            this.getLeaseOptions()
            this.getShippingTypeOptions()
            this.getMoneyOptions()
            this.getsponsor()
            this.addressBtn(e)
            this.getAdressOptions()
            this.getWarehouse()
            this.getApprovalOptions()
			this.getArrange()
            this.getOrderInfo(e)

        },

        onShow() {
            let that = this
            uni.$on('updateData', function(data) {
                // console.log(data);
                if (that.type == 1) {
                    that.formData.salesmanName = data.userName
                    that.formData.salesman = data.userId
                }
                if (that.type == 2) {
                    that.formData.collaboratorName = data.userName
                    that.formData.collaborator = data.userId
                }
                if (that.type == 3) {
                    that.formData.informationProviderName = data.userName
                    that.formData.informationProvider = data.userId

                }

            })

        },
        onBackPress() {
			
            this.getValueS()
            this.getAddress()
			 
        },
        methods: {
			 
			//跳转
			checkWhouse(){
				uni.navigateTo({
					url:"/pages/dialog/warehouse/warehouse"
				})
			},
			// 点击展示地图
			mapFn(){
				var that=this
				uni.chooseLocation({
					success: function (res) {
						console.log('位置名称：' + res.name);
						console.log('详细地址：' + res.address);
						console.log('纬度：' + res.latitude);
						console.log('经度：' + res.longitude);
					that.formData.address=res.address
					}
				});
			},
			// 点击去地图
			mapBtn(){
				uni.navigateTo({
					url:'/pages/map/map'
				})
			},
			// 物流新增
			addArrange(e){
				console.log(e);
				console.log(this.formData);
				var _list = this.formData.logisticsCostList;
				
		        _list.push({
					orderId:this.formData.id,
					orderNo:this.formData.orderNo,
					shippingType:this.formData.shippingType,
					orderProperty:'1',
					warehouseName:this.formData.deliveryWarehouseName,
					outboundNo:'',
					warehousingNo:null,
					driverName:'',
					driverTel:'',
					vehicleInformation:'',
					projectAddress:this.formData.address,
					logisticsExpenses:'',
					projectName:this.formData.projectName
				});
			 this.formData.logisticsCostList = _list
			 console.log(this.formData.logisticsCostList);

			},
			deleteArrange(index){
				console.log(index);
				if(index==0) return false
				this.formData.logisticsCostList.splice(index,1)
				console.log(this.formData.logisticsCostList)
			},
			// 是否需要安排车辆
			getArrange(){
				getDicts('car_required').then(response=>{
					console.log(response);
					this.arrangeOptions.push(response.data)
					this.arrangeOptionDou=response.data
					 this.formData.logisticsName = this.getDictValue(this.arrangeOptionDou, this.formData.logistics)
				})
				
			},
			arrangeFn(e){
				console.log(e);
				this.formData.logistics=e.value[0].dictValue
				this.formData.logisticsName=e.value[0].dictLabel
				this.arrangeShow=false
				if(this.formData.logistics==2){
					this.formData.shippingTypeName="暂无"
					
				}
			},
            getOrderInfo(e) {
                console.log(JSON.parse(e.orderInfo));
                this.formData = JSON.parse(e.orderInfo)
                this.productList = this.formData.productList

            },
            clog() {
                console.log(this.fileList);
            },
            update(val) {
                console.log(val);
                // var map = new Map();
                // Array.from(map);
                var arr = [];
                var map = new Map(val);
                for (var [key, val] of map.entries()) {
                    arr.push([key, val]);
                }

                this.formData.agreement = arr[0][1].responseText.fileName
                console.log(this.formData.agreement);
            },
            // 删除图片
            deletePic(event) {
                this[`fileList${event.name}`].splice(event.index, 1)
            },
            // 新增图片
            async afterRead(event) {
                // 当设置 multiple 为 true 时, file 为数组格式，否则为对象格式
                let lists = [].concat(event.file)
                let fileListLen = this[`fileList${event.name}`].length
                lists.map((item) => {
                    this[`fileList${event.name}`].push({
                        ...item,
                        status: 'uploading',
                        message: '上传中'
                    })

                })
                for (let i = 0; i < lists.length; i++) {
                    console.log();
                    const result = await this.uploadFilePromise(lists[i].url)
                    let item = this[`fileList${event.name}`][fileListLen]
                    this[`fileList${event.name}`].splice(fileListLen, 1, Object.assign(item, {
                        status: 'success',
                        message: '附件图片',
                        url: result
                    }))
                    fileListLen++
                }


                console.log(this.fileList1);
            },
            uploadFilePromise(url) {
                return new Promise((resolve, reject) => {
                    let a = uni.uploadFile({
                        url: 'http://101.132.141.5:8081/common/upload', // 仅为示例，非真实的接口地址
                        filePath: url,
                        header: this.headers,
                        name: 'file',
                        formData: {
                            user: 'test'
                        },

                        success: (res) => {
                            console.log(res);
                            console.log(JSON.parse(res.data));
                            this.formData.enclosure = JSON.parse(res.data).fileName
                            console.log(this.formData.enclosure);
                            setTimeout(() => {
                                resolve(res.data.data)

                            }, 1000)
                            console.log(a);
                        }
                    });
                })
            },

            getAddress(list) {
                
                this.formData.address = list
            },
            getValueS(list) {
                console.log(list, 'B页面传递的数据')
				
                if (Array.isArray(list)) {
                    this.productList = list
					this.productList.forEach(item=>{
						item.quantity=0
					})
                    console.log(this.productList);
                } else {
					
                    // console.log(list);
                    if (list=="undefined") {
                        return false
                    }
					if(list.checkWarehouseName){
						this.formData.deliveryWarehouseName=list.checkWarehouseName
					}else{
						this.formData.customerId = list.id
						this.formData.customerName = list.name
						this.formData.customerRegion = list.region
						this.formData.customerSource = list.source
						this.formData.customerCategory = list.category
						this.formData.customerCategoryName = this.getDictValue(this.customerCategoryOptions, list.category)
						this.formData.customerSourceName = this.getDictValue(this.customerSourceOptions, list.source)
						this.formData.contactName=list.contactName
						this.formData.contactTelephone=list.contactTelephone
						
					}
                     
				}

            },
            // 产品选择
            productListFn(val) {
				console.log(val);
                uni.navigateTo({
                    url: '/pages/dialog/product?warehouseName='+val
                })
            },
            //数量校验库存
            async numberFn(index,item) {
               // 计算押金
                let res = await listStock2({
                    warehouseName: this.formData.deliveryWarehouseName
                })
                res.rows.forEach(item => {
                    if (item.model === this.productList[index].model) {
                        if (item.availableQuantity < this.productList[index].quantity) {
                            // this.$message.warning(`当前仓库${item.model}可用库存数量为${item.availableQuantity}`)
                            this.$refs.uToast.show({
                                type: 'warning',
                                message: `当前仓库${item.model}可用库存数量为${item.availableQuantity}`
                            })
                            this.productList[index].quantity = null
                        }
                    }
                })
				
				// 数量
				let totalCash = 0
				 let arr1 = []
				 this.productList.forEach((item, index) => {
				     if (item.quantity) {
				         totalCash = parseFloat(item.price) * parseFloat(item.quantity)
				         arr1.push(totalCash)
				     }
					 let sum1 = arr1.reduce(function(prev, cur, index) {
					     return prev + cur;
					 })
					 this.formData.depositReceivable = sum1
					   })
            },
            // 计算金额
            setDailyTotalRent(index,val) {
                //计算日租金
                let total = 0 //租金
                let totalCash = 0
                let arr = []
                let arr1 = []
                this.productList.forEach((item, index) => {
                    if (item.quantity && item.dailyRent) {
                        total = parseFloat(item.quantity) * parseFloat(item.dailyRent);
                        totalCash = parseFloat(item.price) * parseFloat(item.quantity)
                        arr1.push(totalCash)
                        arr.push(total)
                    }
                    // console.log(arr)
                    let sum = arr.reduce(function(prev, cur, index) {
                        return prev + cur;
                    })
                    let sum1 = arr1.reduce(function(prev, cur, index) {
                        return prev + cur;
                    })
                    this.formData.depositReceivable = sum1
                    // console.log(sum)
                    this.formData.totalDailyRent = sum

                })
				 //  判断日租金是否符合标准
				
				           if(parseFloat(val)<150){
				             this.formData.purview='1'
							 console.log(this.formData.purview);
				           } 
            },
			
			    receivedFn(){
			      if(parseFloat(this.formData.receivedAmount)<parseFloat(this.formData.depositReceivable)){
			        this.formData.purview='1'
			      }
			    },
            removeProduct(index) {
                this.productList.splice(index, 1)
            },
            // 项目选择
            async openProjict() {
                this.rightShow = true
                this.popupShow = true
                let res = await ProjectList()
                this.projectList = res.rows
            },
            async SeacrchP() {
                let res = await ProjectList(this.SearcProject)
                this.projectList = res.rows
            },
            closeMenu() {
                this.rightShow = false
                this.popupShow = false
            },
            // 选中项目
            checkProject(value) {
                console.log(value);
                this.formData.projectName = value.projectName
                this.formData.consigneeName = value.receiverName
                this.formData.consigneeTel = value.projectTel
                this.formData.address = value.projectAddress
                this.formData.projectSource = value.projectSource
                this.formData.projectSourceName = this.getDictValue(this.projectSourceOptionsDou, value.projectSource)
                this.formData.projectArea = value.projectArea
                // this.formData.projectAreaName=value.projectAreaName
                console.log(this.formData.projectSource, this.projectSourceName);
                this.rightShow = false
                this.popupShow = false
                // 清空查询条件
                this.SearcProject = {
                    projectName: '',
                    customerName: ''
                }
            },
            // 选择器选中事件
            checkedFn(e) {
                if (e.value[0].dictType == 'biz_contract_template') {
                    this.formData.contractTemplate = e.value[0].dictValue
                    this.formData.contractTemplateDuo = e.value[0].dictLabel
                    this.show = false
                }
                if (e.value[0].dictType == 'biz_business_company') {
                    this.formData.businessCompany = e.value[0].dictValue
                    this.formData.businessCompanyDuo = e.value[0].dictLabel
                    this.show = false
                }
                if (e.value[0].dictType == 'biz_order_type') {
                    this.formData.orderType = e.value[0].dictValue
                    this.formData.orderTypeDuo = e.value[0].dictLabel
                    this.show = false
                }
                if (e.value[0].dictType == 'biz_project_source') {
                    this.formData.projectSource = e.value[0].dictValue
                    this.formData.projectSourceName = e.value[0].dictLabel
                    this.show = false
                }
                if (e.value[0].dictType == 'biz_category') {
                    this.formData.customerCategory = e.value[0].dictValue
                    this.formData.customerCategoryName = e.value[0].dictLabel
                    this.show = false
                }
                if (e.value[0].dictType == 'biz_source') {
                    this.formData.customerSource = e.value[0].dictValue
                    this.formData.customerSourceName = e.value[0].dictLabel
                    this.show = false
                }

                if (e.value[0].dictType == 'biz_lease') {
                    this.formData.lease = e.value[0].dictValue
                    this.formData.leaseName = e.value[0].dictLabel
                    this.show = false
					if(e.value[0].dictValue==1){
						console.log(this.lumShow);
						this.lumShow=true
					}else{
						this.lumShow=false
						this.formData.lumpAmount=0
						this.formData.lumpRemark="暂无说明"
					}
                }

                if (e.value[0].dictType == 'biz_shipping_type') {
                    this.formData.shippingType = e.value[0].dictValue
                    this.formData.shippingTypeName = e.value[0].dictLabel
                    this.show = false
                }
                if (e.value[0].dictType == 'pay_ment') {
                    this.formData.depositCollectionMethod = e.value[0].dictValue
                    this.formData.depositCollectionMethodName = e.value[0].dictLabel
                    this.show = false
                }
                if (e.value[0].dictType == 'approval') {
                    console.log(e);
                    this.formData.purview = e.value[0].dictValue
                    this.formData.purviewName = e.value[0].dictLabel
                    this.show = false
					
                }

            },
            // 获取发货仓库
            async getWarehouse() {
                let res = await listWarehouse({
                    pageSize: 1000,
                    pageNum: 1
                })
				console.log(res);
                this.deliveryWarehouseOption.push(res.rows)

            },
            warehouseFn(e) {
                console.log(e);
                this.formData.deliveryWarehouseName = e.value[0].warehouseName
                this.formData.deliveryWarehouseId = e.value[0].id
                this.show = false
            },
            // 项目地区域
            regionConfirm(e) {
                console.log(e);
                this.formData.projectAreaName = e.value[0].text
                this.formData.projectArea = e.value[0].text
                this.show = false

            },
            customerRegion(e) {
                this.formData.customerRegion = e.value[0].text
                this.show = false
            },
            // 项目地址
            adressFn() {
                this.show = 10
                console.log(this.show);
                this.$nextTick(() => {
                    this.$refs.adress.show()
                })
            },
            // 获取地址

            async getAdressOptions() {
                let res = await provinceNameList()
                this.addresslist = await this.getList(res.rows)
            },
            // 收货地址
            async onchange(e) {
                console.log(e);
                let arr = []
                e.detail.value.forEach((item) => {
                    arr.push(item.text)
                })
                this.formData.address = arr.join('')
                this.show = false
            },
            // 业务员 协同人 信息提供人
            userBtn(val) {
                console.log(val);
                this.type = val
                uni.navigateTo({
                    url: "/pages/dialog/user?type=" + val
                })
            },
            // 选择客户
            // 跳转到选择客户页面
            customerBtn() {
                uni.navigateTo({
                    url: "/pages/dialog/customer"
                })
            },
            // 订单发起时间
            orderDateConfirm(e) {
                console.log(e);
                this.formData.orderDate = this.getTime(e.value)
                this.orderDateShow = false
            },
            // 期望到货时间
            expectedArrivalDateConfirm(e) {
                console.log(e);
                this.formData.expectedArrivalDate = this.getTime(e.value)
                this.expectedArrivalDateShow = false
            },
            getDictValue(arr, item) {
                for (var i = 0; i < arr.length; i++) {
                    if (item == arr[i].dictValue) {
                        return arr[i].dictLabel
                    }
                }
            },
            // 时间格式化
            getTime(val) {
                var date = new Date(val);
                var year = date.getFullYear(); //年 ,从 Date 对象以四位数字返回年份
                var month = date.getMonth() + 1; //月 ,从 Date 对象返回月份 (0 ~ 11) ,date.getMonth()比实际月份少 1 个月
                var day = date.getDate(); //日 ,从 Date 对象返回一个月中的某一天 (1 ~ 31)
                //修改月份格式
                if (month >= 1 && month <= 9) {
                    month = "0" + month;
                }
                //修改日期格式
                if (day >= 0 && day <= 9) {
                    day = "0" + day;
                }
                var currentFormatDate = `${year}-${month}-${day}`;
                return currentFormatDate
            },

            // 获取订单编号
            setOrderNo() {
                var date = new Date();
                var year = date.getFullYear(); //年 ,从 Date 对象以四位数字返回年份
                var month = date.getMonth() + 1; //月 ,从 Date 对象返回月份 (0 ~ 11) ,date.getMonth()比实际月份少 1 个月
                var day = date.getDate(); //日 ,从 Date 对象返回一个月中的某一天 (1 ~ 31)
                //修改月份格式
                if (month >= 1 && month <= 9) {
                    month = "0" + month;
                }
                //修改日期格式
                if (day >= 0 && day <= 9) {
                    day = "0" + day;
                }

                let round = Math.floor(Math.random() * (999 - 100)) + 100;
                var currentFormatDate = `${year}${month}${day}`;
                return "ZLDD" + currentFormatDate + round;
            },
            // 获取当前时间
            getNowTime() {
                var date = new Date()
                var month = date.getMonth() + 1;
                var time = date.getFullYear() + "-" + month + "-" + date.getDate();
                return time;
            },

            // 字典数据
            // 是否超权限审批
            getApprovalOptions() {
                getDicts('approval').then(Response => {
                    this.approvaloptions.push(Response.data)
                    this.approvaloptionsDou = Response.data
                    this.formData.purviewName = this.getDictValue(this.approvaloptionsDou, this.formData
                        .purview)
                })
            },
            // 获取客户类别
            getCustomerCategory(val) {
                getDicts('biz_category').then(response => {
                    console.log(response);
                    this.customerCategoryOptions = response.data
                    this.customerCategory.push(response.data)
                    this.formData.customerCategoryName = this.getDictValue(this.customerCategoryOptions, this
                        .formData.customerCategory)
                })
            },
            // 获取客户信息来源
            getCustomerSource() {
                getDicts('biz_source').then(response => {
                    console.log(response);
                    this.customerSourceOptions = response.data
                    this.customerSource.push(response.data)
                    this.formData.customerSourceName = this.getDictValue(this.customerSourceOptions, this
                        .formData.customerSource)
                })

            },
            // 获取合同模板
            async getContractTemplateOptions() {
                const res = await getDicts('biz_contract_template')
                this.contractTemplateOptions.push(res.data)
                this.contractTemplateOptionsDou.push(...res.data)
                console.log(this.contractTemplateOptions, this.contractTemplateOptionsDou);
                this.formData.contractTemplateDuo = this.getDictValue(this.contractTemplateOptionsDou, this.formData
                    .contractTemplate)
            },
            // 获取 业务所属公司
            getBusinessCompanyOptions() {
                getDicts('biz_business_company').then(response => {
                    this.businessCompanyOptions.push(response.data)
                    // console.log(this.businessCompanyOptions);
                    this.businessCompanyOptionsDou.push(...response.data)
                    this.formData.businessCompanyDuo = this.getDictValue(this.businessCompanyOptionsDou, this
                        .formData.businessCompany)
					
                })
            },
            // 获取区域列表
            async getAreaList() {
                const res = await provinceNameList()
                this.regionOptions.push(res.rows)
                this.items = this.getList(res.rows)
            },

            getList(data) {
                data.forEach((item) => {
                    if (item.label) {
                        item.text = item.label
                        delete item.label
                    }
                    if (item.children) {
                        this.getList(item.children)
                    }
                })
                return data
            },


            // 获取订单类型
            getOrderTypeOptions() {
                getDicts('biz_order_type').then(response => {
                    this.orderTypeOptions.push(response.data)
                    this.orderTypeOptionsDou.push(...response.data)
                    this.formData.orderTypeDuo = this.getDictValue(this.orderTypeOptionsDou, this.formData
                        .orderType)
                })
            },
            // 获取项目信息来源
            getProjectSourceOptions() {
                getDicts('biz_project_source').then(response => {
                    this.projectSourceOptions.push(response.data)
                    this.projectSourceOptionsDou = response.data
                    this.formData.projectSourceName = this.getDictValue(this.projectSourceOptionsDou, this
                        .formData.projectSource)
                })

            },
            // 获取租赁形式
            getLeaseOptions() {
                getDicts('biz_lease').then(response => {
                    this.leaseOptions.push(response.data)
                    this.leaseOptionsDou = response.data
                    this.formData.leaseName = this.getDictValue(this.leaseOptionsDou, this.formData.lease)
                })
            },
            // 获取运输方式
            getShippingTypeOptions() {
                getDicts('biz_shipping_type').then(response => {
                    this.shippingTypeOptionsDou = response.data
                    this.shippingTypeOptions.push(response.data)
                    this.formData.shippingTypeName = this.getDictValue(this.shippingTypeOptionsDou, this
                        .formData.shippingType)
                })
            },
            // 押金收取方式
            getMoneyOptions() {
                getDicts('pay_ment').then(response => {
                    // console.log(response);
                    this.MoneyOptions.push(response.data)
                    this.MoneyOptionsDou = response.data
                    this.formData.depositCollectionMethodName = this.getDictValue(this.MoneyOptionsDou, this
                        .formData.depositCollectionMethod)
                })
            },
            //获取发起人
            getsponsor() {
                getLoginUser().then(response => {
                    this.user = response.user;
                    this.formData.salesman = response.user.userId;
                    this.formData.salesmanName = response.user.username;
                    this.formData.sponsor = response.user.userId;
                    this.formData.sponsorName = response.user.username
                    this.formData.sponsorDept = response.user.user.dept.deptId;
                    this.formData.sponsorDeptName = response.user.user.dept.deptName
                })
            },
            // 收货地址
            addressBtn(e) {
                console.log(e);
                this.name = e.name
                this.$nextTick(() => {
                    if (this.name == '收货地址') {
                        this.$refs.pick.show()
                    }
                })


            },
            // 提交按钮
            addBtn() {
				
                // 表单校验
                this.$refs.form.validate().then(async (res) => {
                    this.formData.productList = this.productList
                 var  islength=false
				 if(this.productList.length==0){
					 islength=false
					 this.$refs.uToast.show({
					 	type:'warning',
					 	message:'请选择产品'
					 })
				 }else{
					 this.productList.forEach(item=>{
						 if(item.quantity!==0 && item.quantity!=='' && item.dailyRent !==0 && item.dailyRent!==''){
							 islength=true
						 }else if(this.lumShow==true && item.quantity!==0 && item.quantity!==''){
							 islength=true
						 }else{
							 this.$refs.uToast.show({
							 	type:'warning',
							 	message:'关联产品信息是否完整'
							 })
						 }
					 })
				 }
				 
                    if (res && islength) {
                        this.BtnShow = true

                    }else{
						this.$refs.uToast.show({
							type:'warning',
							message:'请检查信息是否填写完整'
						})
					}
                }).catch((error) => {
                    console.log(error);
                })

            },
            async BtnModel() {
                this.BtnShow = false
                // 校验项目
                let res1 = await ProjectList({
                    projectName: this.formData.projectName
                })
                if (res1.rows.length == 0) {
                    let projectForm = {
                        // customerId:this.formData.customerId,
                        customerName: this.formData.customerName, //客户姓名
                        userId: this.formData.sponsor, //用户id
                        userName: this.formData.sponsorName, //用户姓名
                        projectName: this.formData.projectName, //项目名称
                        projectAddress: this.formData.address, //项目地址
                        projectArea: this.formData.projectArea, //项目区域
                        projectAreaName: this.formData.projectAreaName, //项目区域名
                        projectSource: this.formData.projectSource, //项目来源
                        projectTel: this.formData.consigneeTel, //联系人电话
                        receiverName: this.formData.consigneeName, //联系人姓名
                    }
                    await addProject(projectForm)
                    this.$refs.uToast.show({
                        type: 'success',
                        message: '已成功添加项目'
                    })
                }
                // 校验客户
                let res2 = await listCustomer({
                    name: this.formData.customerName
                })
                if (res2.rows.length == 0) {
                    let customerForm = {
                        name: this.formData.customerName,
						 
                        source: this.formData.customerSource,
                        sourceName: this.formData.customerSourceName,
                        contactName: this.formData.consigneeName,
                        contactTelephone: this.formData.consigneeTel,
                        region: this.formData.customerRegion,
                        category: this.formData.customerCategory,
                        categoryName: this.formData.customerCategoryName,
                        address: this.formData.address,
                        chargePersonId: this.formData.sponsor,
                        chargePersonName: this.formData.sponsorName,
                        collaboratorId: this.formData.collaborator,
                        collaboratorName: this.formData.collaboratorName,
                    }
                    await addCustomer(customerForm)
                    this.$refs.uToast.show({
                        type: 'success',
                        message: '已成功添加客户'
                    })

                }
                if (this.formData.id) {
					if(this.formData.orderStatus==12){
						await addOrder(this.formData)
						this.$refs.uToast.show({
						    type: 'success',
						    message: '添加成功',
						    complete() {
						        uni.redirectTo({
						            url: '/pages/order/index'
						        })
						    }
						})
					}else if(this.formData.orderStatus=13){
						await updateOrder(this.formData)
						this.$refs.uToast.show({
						    type: 'success',
						    message: '修改成功',
						    complete() {
						        uni.redirectTo({
						            url: '/pages/order/index'
						        })
						    }
						})
					}
                   
                } else {
                    await addOrder(this.formData)
                    this.$refs.uToast.show({
                        type: 'success',
                        message: '添加成功',
                        complete() {
                            uni.redirectTo({
                                url: '/pages/order/index'
                            })
                        }
                    })
                }


            },

            // 返回
            back() {
                uni.redirectTo({
                    url: "/pages/order/index"
                })
            }
        }
    }
</script>
<style lang="scss">
	//地图
	.adress{
		   position: relative;
		.map{
			width: 40px;
			height: 40px;
			
			border: solid 1px #eee;
			box-shadow:2px 2px  2px #eee ;
			
			position: absolute;
			right: 10px;
			bottom: 10px;
			
		}
		
	}
    .form {
        background-color: #fff;
        padding-left: 10px;
        padding-right: 10px;

    }

    .popupShow {
        overflow: hidden;
        position: fixed;
    }

    // 无权限弹出层
    .poup {
        display: flex;
        flex-direction: column;
        align-items: center;
    }

    .box {
        background-color: #fff;

        .box-item {
            margin: 0 10px;
            font-size: 12px;
            border-bottom: solid 1px #f4f4f4;
        }

    }

    .bg {
        background-color: #fff;
    }

    .popup-box {
        min-width: 250px;
        min-height: 100px;
        text-align: center;

        .title-top {
            height: 40px;
            line-height: 40px;
            font-size: 16px;
            font-weight: 600;
        }

        .box-bottom {
            display: flex;
            justify-content: space-around;
            height: 40px;
            line-height: 40px;

            view {
                width: 50%;
            }
        }
    }

    // 项目弹框
    .projectBox {
        min-width: 300px;
        height: 100%;
        margin: 10px;

        .info {
            position: relative;
            width: 100%;
            min-height: 100px;
            padding: 10px;
            font-size: 12px;
            border: solid 1px #c3c3c3;
            margin-bottom: 5px;

            .btn {
                position: absolute;
                right: 10px;
                bottom: 25px;
                color: #fd9540;
                font-size: 14px;
            }
        }
    }

    .address {
        position: relative;

        .icon {
            position: absolute;
            right: 0;
            bottom: 0;
            display: inline-block;
            width: 30px;
            height: 30px;
        }
    }
</style>
